package com.zut.edu;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;

import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import com.zut.edu.utils.StringUtils;

public class WelcomeActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        QMUIStatusBarHelper.translucent(this);//沉浸式
        //两秒钟进入主页面
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                preJudge();
            }
        },2000);
    }

    private void preJudge(){
        SharedPreferences sp = getSharedPreferences("nfc_pre",MODE_PRIVATE);
        String user_data = sp.getString("user","");
        Log.e("user",user_data);
        if(StringUtils.isEmpty(user_data)){
            Intent intent = new Intent(this,LoginActivity.class);
            startActivity(intent);
            finish();
        }
        else {
            String userIdentit =  StringUtils.getLocalitem(this,"user","userIdentity");
            switch (userIdentit){
                case "2":
                    startActivity(new Intent(WelcomeActivity.this,MainActivity.class));
                    finish();
                    break;
                default:
                    startActivity(new Intent(WelcomeActivity.this,MainOpActivity.class));
                    finish();
                    break;
            }

        }
    }
}
